package com.hsd.service.impl;

import com.hsd.mapper.RDeviceInforMapper;
import com.hsd.mapper.RDeviceMapper;
import com.hsd.model.RDevice;
import com.hsd.service.DeviceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class DeviceServiceImpl implements DeviceService {
    @Autowired
    private RDeviceMapper deviceMapper;
    @Autowired
    private RDeviceInforMapper deviceInforMapper;

    public List<RDevice> GetDeviceList() {
        // TODO 自动生成的方法存根
        return deviceMapper.GetDeviceList();
    }
    public List<RDevice>MultiTableq(){
        return deviceMapper.MultiTableq();
    }
    public List<RDevice>MultiTableqBymemberName(String membername){
        return  deviceMapper.MultiTableqBymemberName(membername);
    }


    public int add(RDevice device){
        return deviceMapper.insertSelective(device);
    }
    public int delete(int deviceid) {
        int ans_d=deviceMapper.deleteByPrimaryKey(deviceid);
        int ans_i=deviceInforMapper.deleteByDeviceId(deviceid);
        if(((ans_d!=0?1:0) + (ans_i!=0?1:0))==2)
        {
            return 1;
        }
        return 0;
    }
    public int ChangeDevice(RDevice device){
        return deviceMapper.updateByPrimaryKeySelective(device);
    }
    public RDevice search(int deviceid){
        return deviceMapper.selectByPrimaryKey(deviceid);
    }

}


